<template>
  <el-dialog :title="title" :close-on-click-modal="false" width="60vw" :visible.sync="visible"
             :append-to-body="true" @close="clearDataList()">
    <el-table v-loading="loading" :data="dataForm" border style="width: 100%;">
      <el-table-column type="index" align="center" width="60px" label="序号"></el-table-column>
      <el-table-column prop="jjxFl" align="center" label="奖金项分类"></el-table-column>
      <el-table-column prop="jjxName" align="center" label="奖金项名称"></el-table-column>
      <el-table-column prop="useJe" align="center" label="使用金额(元)">
        <template slot-scope="scope">
          {{ $formatNum(scope.row.useJe) }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="使用时间">
        <template slot-scope="scope">
          <div>
            <span>{{ $moment(scope.row.useTime).format("YYYY-MM-DD") }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="remark" align="center" label="备注"></el-table-column>
    </el-table>
    <div class="avue-crud__pagination">
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
                     :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background
                     layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" plain @click="clearDataList">关闭</el-button>
    </span>
  </el-dialog>
</template>
<script>
import {getJiangJinDetail} from '@/api/jiangjin/jiangjinjjcsymxb'

export default {
  data() {
    return {
      deptId: '',
      deptName: '',
      visible: false,
      dataForm: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      loading: false,
      title:""
    }
  },
  created() {

  },
  methods: {
    init(deptId,deptName) {
      this.visible = true
      this.deptId = deptId
      this.deptName = deptName
      this.title = '奖金池使用明细--' + deptName
      this.getDataForm()
    },

    // 查询指定机构奖金池使用明细列表
    getDataForm() {
      this.loading = true
      getJiangJinDetail({
        current: this.pageIndex,
        size: this.pageSize,
        deptId: this.deptId
      }).then(response => {
        this.dataForm = response.data.data.records
        this.totalPage = response.data.data.total
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    clearDataList() {
      this.visible = false
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataForm()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataForm()
    },

  }
}

</script>

<style scoped>

</style>
